Gaining a mechanistic understanding of how spatiotemporal patterns of neural activity give rise to sensory perception is a fundamental aim of neurobiology. Despite intensive investigation, substantial disagreements remain over the nature of neural codes, and basic operating principles of the cortex remain obscure. Despite recent advances in optogenetics, new experimental approaches are required to address the problem. The goal of this proposal is to develop a new experimental paradigm capable of both monitoring and enforcing spatiotemporal patterns of neuronal activity during behavior and employ it to dissect how cortical circuits encode information during a sensory discrimination task. By combining multiphoton microscopy and new advances in optogenetics, we will complete development of a system capable of simultaneously imaging and stimulating unique sequences of neurons in three dimensions during active sensation in an awake mouse with millisecond temporal resolution. By manipulating identified neurons during sensation, we will mechanistically probe how the activity of highly discriminating neurons influences activity in the cortical network and biases sensory perception.